﻿using SuperFrame.Charts.Modes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace SuperFrame.Charts
{
    /// <summary>
    /// TemperatureHumidityControl.xaml 的交互逻辑
    /// </summary>
    public partial class TemperatureHumidityControl : UserControl, INotifyPropertyChanged
    {
        public TemperatureHumidityControl()
        {
            InitializeComponent();
            this.DataContext = this;
            this.Loaded += TemperatureHumidityControl_Loaded;
        }

        void TemperatureHumidityControl_Loaded(object sender, RoutedEventArgs e)
        {
            DispatcherTimer timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(3);
            timer.Tick += timer_Tick;
            timer.Start();
        }

        void timer_Tick(object sender, EventArgs e)
        {
            Random random = new Random();
            double hValue = random.Next(0, 100);
            HumidityControl.CurrentValue = hValue;
            Random random2 = new Random();
            double tValue = random.Next(-30, 50);
            TemperatureControl.CurrentValue = tValue;
        }
        private List<IntervalMode> temperatureIntervalList;

        public List<IntervalMode> TemperatureIntervalList
        {
            get
            {
                return temperatureIntervalList;
            }
            set
            {
                temperatureIntervalList = value;
                RegistProperty("TemperatureIntervalList");
            }
        }

        private List<IntervalMode> humidityIntervalList;

        public List<IntervalMode> HumidityIntervalList
        {
            get
            {
                return humidityIntervalList;
            }
            set
            {
                humidityIntervalList = value;
                RegistProperty("HumidityIntervalList");
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        public void RegistProperty(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
